﻿using AutoMapper;
using Nop.Admin.Models.WindAlert;
using Nop.Core.Domain.WindAlert;
using Nop.Core.Infrastructure;
using Nop.Services.Seo;

namespace Nop.Admin.WindAlert
{
    public class AutoMapperStartupTask : IStartupTask
    {
        public void Execute()
        {
            //wind spots
            Mapper.CreateMap<Spot, SpotModel>()
                .ForMember(dest => dest.SeName, mo => mo.MapFrom(src => src.GetSeName(0, true, false)));
            Mapper.CreateMap<SpotModel, Spot>();
            //Camera
            Mapper.CreateMap<Camera, CameraModel>()
                .ForMember(dest => dest.SeName, mo => mo.MapFrom(src => src.GetSeName(0, true, false)));
            Mapper.CreateMap<CameraModel, Camera>()
                .ForMember(dest => dest.CreatedOnUtc, dt => dt.Ignore())
                .ForMember(dest => dest.UpdatedOnUtc, dt => dt.Ignore())
                .ForMember(dest => dest.Deleted, dt => dt.Ignore());
            //wind spotsGroup
            Mapper.CreateMap<SpotsGroup, SpotsGroupModel>();
            Mapper.CreateMap<SpotsGroupModel, SpotsGroup>();
            //Mobile Device
            Mapper.CreateMap<MobileDevice, MobileDeviceModel>()
                .ForMember(dest => dest.CreatedOn, mo => mo.Ignore())
                .ForMember(dest => dest.UpdatedOn, mo => mo.Ignore());
            Mapper.CreateMap<MobileDeviceModel, MobileDevice>()
                .ForMember(dest => dest.CreatedOnUtc, mo => mo.Ignore())
                .ForMember(dest => dest.UpdatedOnUtc, mo => mo.Ignore());
        }

        public int Order
        {
            get { return 0; }
        }
    }
}